import {WidgetClass} from "../atom/widget";

export class Carousel extends WidgetClass {
  constructor(options = {}) {
    super(options);
    const {ports,UI} = options;
    if (UI) {
      this.UI.data = UI.data
    } else {
      this.UI.data = {
        mode:"image",
        localImageList: [],
        netImageList: [],
        netVideoList:[],
        playInterval: 4,
      };
    }
    if (ports) {
      this.ports = ports;
    } else {
      this.ports = this.assembleDefaultPorts();
    }
  }

  assembleDefaultState(options = {}) {
    const superState = super.assembleDefaultState(options);
    return {
      ...superState
    };
  }

  assembleDefaultPorts() {
    const superState = super.assembleDefaultPorts();
    return {
      ...superState,
      values: [
        ...superState.values,
        {
          name: "资源类型",
          key: "mode",
          type:"string",
          value:"image",
        },
        {
          name: "网络图片",
          key: "netImageList",
          type: "list",
          value: [],
        },
        {
          name: "网络视频",
          key: "netVideoList",
          type: "list",
          value: [],
        },
        {
          name: "图片切换时间",
          key: "playInterval",
          type: "string",
          value: null,
        },
      ],
      events: [],
    };
  }
}
